package com.common.pojo.vo;

import com.common.enums.ResultEnum;

import java.io.Serializable;

/**
 * @Brief 通用返回实体类
 * @Author chenyl
 * @Date 2023-08-01
 * @Version 1.0.0
 */
public class ResultVO<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 状态码
     */
    private int code;
    /**
     * 状态
     */
    private boolean status;
    /**
     * 信息
     */
    private String message;
    /**
     * 数据
     */
    private T data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ResultVO() {
    }

    public ResultVO(ResultEnum enumEntity) {
        this.code = enumEntity.getId();
        this.status = true;
        this.message = enumEntity.getMessage();
    }

    public ResultVO(int code, boolean status, String message, T data) {
        this.code = code;
        this.status = status;
        this.message = message;
        this.data = data;
    }

    @Override
    public String toString() {
        return "{code:" + code +
                ",status:" + status +
                ",message:" + message +
                ",data:" + data +
                "}";
    }
}
